//绘制图表
let canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');

let x = 40;
let y = 280;
let xWidth = 30;
//绘制图标坐标轴
coordinateDrawing();
//输入两个高度参数，生成两个相邻对比的条形图
graphicList(200, 160);
graphicList(140, 130);
graphicList(120, 190);
graphicList(160, 140);
graphicList(150, 200);


let sql='';
 
// //获取当前所有单个表的所有数据]
//categor为数据库表的名称
//学生总数插入
getNum('students', studentsInit, 'SELECT COUNT(*)total FROM students WHERE is_del=1;');


function studentsInit(num){
  $('.wf-students').text(num+10);
}

//学生新增插入

getNum('students', studentsAddInit, 'SELECT COUNT(*)total FROM students WHERE is_del=1;');

function studentsAddInit(num) {
  $('.wf-new-students').text(num)
}
//总课程插入
getNum('courses', courseInit, 'SELECT COUNT(*)total FROM`courses` WHERE is_del = 1');

function courseInit(num) {
  $('.wf-course').text(num)
}

//收费插入
getNum('students', tollInit, 'SELECT COUNT(*)total FROM students WHERE is_del = 1; ');

function tollInit(num) {
  $('.wf-toll').text((num) *4500)
}
//老师名单列表
getNum('teachers', teacherListRendering,'SELECT teacher_id  ,teacher_name , teacher_standing FROM teachers WHERE is_del=1 LIMIT 0,6;');

//点击查看档案，获取id，跳转页面
$('.wf-three-table').on('click',".wf-teacher-introduce",(e)=>{
  //获取当前点击的老师的id
  teacherId = e.target.id;
  localStorage.setItem('teacherId', teacherId);
  location.href ='xzh_pages/teacherIntroduce.html';
})
  
 // 学生名单列表
getNum('students', studentListRendering, 'SELECT id, name, class_name, years FROM(SELECT * FROM`students` LEFT JOIN`studentscent`  USING(id))AS list1 LEFT JOIN classes USING(class_id) WHERE is_del=1 limit 0, 5;');

//点击查看所有的老师
$('.wf-check-all-teachers').on('click',()=>{
  location.href ='xzh_pages/teacherPage.html';
});
//点击查看所有的学生
$('.wf-check-all-students').on('click', ()=> {
  location.href = 'ly_pages/student_list.html';
});
//点击查看详情，获取id，跳转页面到学生详情
$('.wf-table-list').on('click', ".wf-student-file",  (e)=> {
  //获取当前点击的学生的id
  studentId = e.target.id;
  console.log(studentId)
  //数据接口，用于传递点击的那个学生
  location.href = 'ly_pages/student_details.html?userId=' + studentId ;
})